<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductsTable extends Migration
{
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->string('title')->index();
            $table->unsignedBigInteger('user_id')->index()->default(0)->nullable()->comment('belongs to this user');
	        $table->unsignedBigInteger('brand_id')->index()->default(0)->nullable()->comment('belongs to this brand');
	        $table->unsignedBigInteger('type_id')->index()->default(0)->nullable()->comment('belongs to this brand');
	        $table->unsignedBigInteger('standard_id')->index()->default(0)->nullable()->comment('belongs to this brand');
	        $table->integer('age')->default(0);
	        $table->integer('mileage')->default(0);
	        $table->integer('times')->default(0);
	        $table->integer('displacement')->default(0);
	        $table->decimal('price', 10, 2)->nullable()->comment('market price');
	        $table->string('image')->nullable()->comment('cover image');
	        $table->text('description')->nullable();
	        $table->string('province')->nullable();
	        $table->string('province_code')->default(0);
	        $table->string('city')->nullable();
	        $table->string('city_code')->default(0);
	        $table->boolean('is_open')->default(true);
	        $table->boolean('is_sale')->default(true);
	        $table->boolean('is_hidden')->default(true);
	        
	        $table->unsignedBigInteger('order')->default(100000000);
	         $table->dateTime('transfer_at')->nullable();
	        $table->softDeletes();
	        $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('products');
    }
}
